#ifndef _APPVIEWIMPL_H_
#define _APPVIEWIMPL_H_

#include "stdafx.h"

//{a7957a54-37cb-42a4-9ee8-599168c2a3d1}
_DEF_CLSID_IMPL(CLSID_AppView, 0xA7957A54, 0x37CB, 0x42A4, 0x9E, 0xE8, 0x59, 0x91, 0x68, 0xC2, 0xA3, 0xD1)

class CAppViewImpl : public IPlugin, public IPluginRun, public IHttpProc, public CUnknownImp
{
public:
    CAppViewImpl(void);
    virtual ~CAppViewImpl(void);

public:
    BEGIN_STDCOM_MAP
    STDCOM_INTERFACE_ENTRY_UNKNOWN_(IPlugin)
    STDCOM_INTERFACE_ENTRY(IPlugin)
    STDCOM_INTERFACE_ENTRY(IPluginRun)
    STDCOM_INTERFACE_ENTRY(IHttpProc)
    END_STDCOM_MAP

    // IPlugin
    std_method(Init)(IBase* pRot, IBase* pBase);
    std_method(Uninit)();

    // IPluginRun
    std_method(Start)(_pid_t pid, unsigned int type);
    std_method(Stop)(unsigned int exit);

    // IHttpProc
    std_method(OnHttpAuth)(ULONG event);
    std_method(OnHttpNotify)(crtid cid, crterr err);
    std_method(OnHttpSendParam)(UCHAR* key, buf_len klen, UCHAR* value, buf_len vlen);
    std_method(OnHttpRecvParam)(UCHAR* key, buf_len klen, UCHAR* value, buf_len vlen);
    std_method(OnHttpSendHeaded)(UCHAR* data, buf_len size);
    std_method(OnHttpRecvHeaded)(UCHAR* data, buf_len size);
    std_method(OnHttpSendBody)(UCHAR* data, buf_len size);
    std_method(OnHttpRecvBody)(UCHAR* data, buf_len size);

private:
    std_method(InitBus)();
    std_method(UnInitBus)();

private:
    _lComPtr<IRot> m_pRot;
    _lComPtr<IAsynFrame> m_pIAsynFrame;
    _lComPtr<IHttp> m_pIHttp;
    _lComPtr<IModBus> m_pIModBus;
    _lComPtr<IMsgBus> m_pIMsgBus;
    _lComPtr<IBroker> m_pIBroker;
    _lComPtr<IConsumer> m_pIConsumer;
    _lComPtr<IProducer> m_pIProducer;
    _lComPtr<IAgent> m_pIAgent;

    _lComPtr<IUIBase> m_pIUiBase;
    _lComPtr<IUIWindow> m_pIUiWindow;
    _lComPtr<IUIMessageLoop> m_pIUiMessageLoop;
    _lComPtr<ILogs> m_pILogs;
};
#endif
